Skip to content

[SYCL] Forward decl free func kernel template args#21285

Open
KornevNikita wants to merge 6 commits intointel:syclfrom
KornevNikita:forward-declare-struct
Open

[SYCL] Forward decl free func kernel template args#21285
KornevNikita wants to merge 6 commits intointel:syclfrom
KornevNikita:forward-declare-struct

Conversation

@KornevNikita
Copy link
Contributor

@KornevNikita KornevNikita commented Feb 13, 2026

CMPLRLLVM-72459
This patch fixes compilation error that occur when a free function kernel has a template parameter.
Visit and forward declare template args of free functions kernels.

@KornevNikita KornevNikita marked this pull request as ready for review February 17, 2026 18:06
@KornevNikita KornevNikita requested review from a team as code owners February 17, 2026 18:06
Copy link
Contributor

@tahonermann tahonermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding my approval with a comment regarding additional tests that I think would be useful.

// CHECK-NEXT: template <typename scalar_t, typename F> void templated(scalar_t *);
// CHECK-NEXT: static constexpr auto __sycl_shim1() {
// CHECK-NEXT: return (void (*)(float *))templated<float, struct TestStruct<float>>;
// CHECK-NEXT: }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving the test declarations to a new test file. This suffices for the reported issue, so I'll accept the review.

If you aren't opposed, here are some other cases that I think would be useful to test.

template <auto V>
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 1)]]
void ffk1() {
}
template <typename> struct TestClassTemplate1 {
};
struct TestClass1;
template void ffk1<TestClassTemplate1<TestClass1>{}>();

template <typename T, template<typename> class CT>
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 1)]]
void ffk2(CT<T>) {}
template <typename> struct TestClassTemplate2 {
};
struct TestClass2;
template void ffk2(TestClassTemplate2<TestClass2>);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Sure, additional tests are always welcome. But this patch got a bunch of approvals and additional test cases may unveil some additional issues, so I will proceed with merging this one and creating a follow-up patch to not bother approvers with another round of review here.

@KornevNikita
Copy link
Contributor Author

@uditagarwal97 take a look please, just an E2E test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments